home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / packet / p_tapr / tnchst / blp.inc < prev    next >
Text File  |  1991-01-01  |  3KB  |  145 lines

  1. #ifndef BLP_INCLUDES
  2.  
  3. #define    BLP_INCLUDES
  4.  
  5. #define    NLINKS        50
  6.       /* storage for BLPCB's is allocated statically */
  7.  
  8. #define    BLP_RETRY_TIME    30
  9.     /* retry time in seconds - must be 0<=x<=32767 */
  10.  
  11. #define BLP_MAX_TRIES    10
  12. #define    BLP_MAX_OUTSTANDING 15
  13.  
  14. #define    BLPDATASIZE    256        /* max size of data fields */
  15. #define    ADDRSIZE    9*7
  16.  
  17.   /* if loopback 1 then all outgoing lcns are XOR'd with 0xC0 */
  18. #define LOOPBACK 0
  19.  
  20. #define    BLP_EVENT_TRACE    FALSE
  21.  
  22.     /* tnc will send broadcast packets on this channel */
  23. #define    BROADCAST_LCN    0x71
  24.  
  25.  
  26.     /* BLP command codes */
  27. #define    CS    0x02
  28. #define    CSEMAIL    0x12        /* special only */
  29. #define    CCC    0x04
  30.  
  31. #define    CCLR    0x08
  32. #define    CCLRD    0x09
  33.  
  34. #define    CSTENQ    0x10
  35. #define    CSTREP    0x11
  36.  
  37. #define    UDATA    0x20
  38. #define    DDATA    0x80
  39. #define    DACK    0x90
  40. #define    DBUSY    0xA0
  41.  
  42.  
  43. struct   bframe_struct {        /* structure of blp frames */
  44. /*    byte    dest;
  45.     byte    source;            /* dest, source are optional */
  46.  
  47.     byte    lcn ;            /* logical channel */
  48.     byte    cmd ;            /* command */
  49.     byte    data[ BLPDATASIZE ] ;    /* data field */
  50.     };
  51.  
  52. struct    datapacket_struct {        /* structure holding pktzd tx data*/
  53.     word    len ;            /* for linked list */
  54.     struct    datapacket_struct *next ;    /* linked list - next pkt */
  55.     byte    data[ BLPDATASIZE ] ;
  56.     };
  57.  
  58.  
  59.     /* structure controls all aspects of a particular BLP interface,
  60.        specifically BLP for .lcn */
  61. struct    blpcb_struct {
  62.     byte    lcn ;            /* lcn for this link */
  63.     byte    local_chan ;        /* upper level's token for this link */
  64.     byte    address[ ADDRSIZE ];    /* upper level called address */
  65.  
  66.     byte    bsstate, bdstate ;    /* sup'vy and data state variables */
  67.     byte    bdtxseq, bdrxseq ;    /* sequence #'s */
  68.     struct datapacket_struct txpackets ; /* head node of lkd list of pkts */
  69.                         /* bit wasteful */
  70.  
  71.     byte    outstanding ;        /* # of outstanding pkts in linked lst*/
  72.     byte    retry_count ;
  73.     int    timer ;            /* (-1) = stopped, 0 = expired,
  74.                      anything else means running */
  75.     byte    email ;        /* true if outgg call is for email port */
  76.     };
  77.  
  78.  
  79.     /* structure used by state tables */
  80. struct    state_entry {
  81.                 /* handler for the state */
  82.     void    (*action_handler) (struct blpcb_struct *,
  83.                    struct bframe_struct *, word );
  84.     byte    newstate ;    /* new state */
  85.     };
  86.  
  87.  
  88.  
  89. /**** states
  90.  
  91.          Note that states must start at state 1! ****/
  92.  
  93. #define    NSSTATES    7
  94. #define    NSEVENTS    11
  95. #define    NDSTATES    4
  96. #define    NDEVENTS    8
  97.  
  98. /*    Supervisory states */
  99.  
  100. #define    BSIDLE        1
  101. #define    BSLCSETUP    2
  102. #define    BSRCSETUP    3
  103. #define    BSLSETWT    4
  104. #define    BSRSETWT    5
  105. #define    BSCLEARWT    6
  106. #define    BSDATA        7
  107.  
  108.     /* data states */
  109.  
  110. #define    BDIDLE        1
  111. #define    BDWAIT        2
  112. #define BDBSY        3
  113. #define BDBSYWT        4
  114.  
  115.  
  116.     /** events **/
  117.         /** received supervisory packets **/
  118. #define    RCVD_CS        0
  119. #define    RCVD_CA        1
  120. #define    RCVD_CCC    2
  121. #define    RCVD_CCCACK    3
  122. #define    RCVD_CCLR    4
  123. #define    RCVD_CCLRD    5
  124.  
  125.         /** local events **/
  126. #define    LSTART        6
  127. #define    LSTOP        7
  128. #define    LCNCTD        8
  129. #define    LRETRY        9
  130. #define    LSTIMER        10
  131.  
  132.         /** data events **/
  133. #define    LNEWDATA    20
  134. #define    LBLPACK        21
  135. #define    LDTIMER        22
  136. #define    LDATABUSY    23
  137. #define    LRXDATA        24
  138. #define    LRXACK        25
  139. #define    LUNBUSY        26
  140. #define    LRXCSTENQ    27
  141.  
  142. #define    FIRST_DATA_EVENT LNEWDATA
  143.  
  144. #endif
  145.